{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lusx/anaconda3/envs/torch/lib/python3.6/site-packages/torch/nn/modules/upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead.\n",
      "  warnings.warn(\"nn.{} is deprecated. Use nn.functional.interpolate instead.\".format(self.name))\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([1020, 50])\n",
      "torch.Size([85, 50])\n",
      "0.6352941176470588\n"
     ]
    }
   ],
   "source": [
    "from naive_bayes import predict, gnb\n",
    "\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GCHAMGARKDF5DY4F9X4Q27ZM8ZXQJCHA_4UPLE8CBS8YSPLEJ16Y92UNGB3TQIAMV95I5HFXK2IZG_4WPIBY5\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.011764705882352941"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "char = [['A', 'B', 'C', 'D', 'E', 'F'],\n",
    "        ['G', 'H', 'I', 'J', 'K', 'L'],\n",
    "        ['M', 'N', 'O', 'P', 'Q', 'R'],\n",
    "        ['S', 'T', 'U', 'V', 'W', 'X'],\n",
    "        ['Y', 'Z', '1', '2', '3', '4'],\n",
    "        ['5', '6', '7', '8', '9', '_']]\n",
    "\n",
    "series = []\n",
    "real_a = 'WQXPLZCOMRKO97YFZDEZ1DPI9NNVGRQDJCUVRMEUOOOJD2UFYPOO6J7LDGYEGOA5VHNEHBTXOO1TDOILUEE5BFAEEXAW_K4R3MRU'\n",
    "real_b = 'MERMIROOMUHJPXJOHUVLEORZP3GLOO7AUFDKEFTWEOOALZOP9ROCGZET1Y19EWX65QUYU7NAK_4YCJDVDNGQXODBEV2B5EFDIDNR'\n",
    "train_a = 'EAEVQTDOJG8RBRGONCEDHCTUIDBPUHMEM6OUXOCFOUKWA4VJEFRZROLHYNQDW_EKTLBWXEPOUIKZERYOOTHQI'\n",
    "\n",
    "for i in range(85):\n",
    "    col_pred_set = predict[i+6:i+12]\n",
    "    row_pred_set = predict[i:i+6]\n",
    "    if np.max(col_pred_set, axis=0) != 0:\n",
    "        col_pred = np.where(col_pred_set == np.max(col_pred_set, axis=0))[0][0]\n",
    "    else:\n",
    "        col_pred = np.random.randint(6)\n",
    "    if np.max(row_pred_set, axis=0):\n",
    "        row_pred = np.where(row_pred_set == np.max(row_pred_set, axis=0))[0][0]\n",
    "    else:\n",
    "        row_pred = np.random.randint(6)\n",
    "    \n",
    "    series.append(char[int(row_pred)][int(col_pred)])\n",
    "\n",
    "series = ''.join(series)\n",
    "\n",
    "print(series)\n",
    "counter = 0\n",
    "for i in range(len(train_a)):\n",
    "    if train_a[i] == series[i]:\n",
    "        counter += 1\n",
    "\n",
    "counter / len(train_a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.302585092994046"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.log(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:torch]",
   "language": "python",
   "name": "conda-env-torch-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
